# 固定阈值二值化(THRESHOLO_BINARY)
# 非黑即白（>=127==>255;<127==>0）

import cv2
import numpy as np

img = cv2.imread('D:/python/opencv-processing/laiya.jpg')

h,w,c = img.shape
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

for i in range(h):
    for j in range(w):
        # 执行非黑即白
        if gray[i,j]>=127:
            gray[i,j]=255
        else:
            gray[i,j]=0

cv2.imshow('erzhihua',gray)
cv2.waitKey(0)
